// part1:C11:ex11.8.cpp
// word in same vector, different set.
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <string>
#include <algorithm>

using namespace std;

string& trans(string& s)
{
    for (int pos = 0; pos < s.size(); pos++)
    {
        if (s[pos] >= 'A' && s[pos] <= 'Z')
        {
            s[pos] -= ('A' - 'a');
        }
        else if (s[pos] == ',' || s[pos] == '.')
        {
            s.erase(pos, 1);
        }
    }
    return s;
}
int main(int argc, char *argv[])
{
    ifstream in(argv[1]);
    if (!in)
    {
        cout << "failed open input file" << endl;
        exit(1);
    }

    vector<string> unique_word;
    string word;
    while (in >> word)
    {
        trans(word);
        if (find(unique_word.begin(), unique_word.end(),
                    word) == unique_word.end())
        {
            unique_word.push_back(word);
        }
    }

    for (const auto &w : unique_word)
    {
        cout << w << " is : ";
    }
    cout << endl;

    return 0;
}
